package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.TradingPoolChangeLog;
import com.sc.nft.enums.TradingPoolChangeTypeEnum;
import com.sc.nft.mapper.TradingPoolChangeLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

/**
 * @author PC
 * @description 针对表【sc_trading_pool_change_log(交易池日志)】的数据库操作Dao
 * @createDate 2024-10-26 13:55:36
 */
@Slf4j
@Repository
public class TradingPoolChangeLogDao extends ServiceImpl<TradingPoolChangeLogMapper, TradingPoolChangeLog> {

    /**
     * 分页查询
     *
     * @param page
     * @param confId
     * @param daoId
     * @param type
     * @return
     */
    public IPage<TradingPoolChangeLog> page(Page<TradingPoolChangeLog> page, Long confId, Long daoId, TradingPoolChangeTypeEnum type) {
        LambdaQueryWrapper<TradingPoolChangeLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TradingPoolChangeLog::getTradingPoolConfigId, confId);
        wrapper.eq(TradingPoolChangeLog::getDaoId, daoId);
        wrapper.eq(TradingPoolChangeLog::getType, type);
        wrapper.orderByDesc(TradingPoolChangeLog::getRecordTime);
        return page(page, wrapper);
    }

}
